package com.gy.spark.core

import org.apache.spark.{SparkConf, SparkContext}

/**
 * 本地模式运行wc
 */
object WordCount {

  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
      .setAppName(WordCount.getClass.getSimpleName)
      .setMaster("local[2]")

    val sc = new SparkContext(sparkConf)

    sc.setLogLevel("warn")

    sc.textFile("hbase/input_user.txt")
      .flatMap(_.split(" "))
      .map((_, 1))
      .reduceByKey(_ + _)
      .sortBy(_._2, false)
      .foreach(println)

    sc.stop()

  }


}
